package game.Actors;

import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Vector2f;
/**
 * This class represents a fading bullet, extending the bullet class.
 * The fading bullet will remove itself when it has traveled a given distance.
 * @author Sebastian Isheden and Victor Beer
 */
public class FadingBullet extends Bullet{
	private Vector2f originalPosition;
	private float fadeDistance;
	/**
	 * Creates a fading bullet with given parameters.
	 * @param image	The image of the bullet fired.
	 * @param position The starting position of the bullet.
	 * @param speed The speed the bullet will traverse the screen.
	 * @param direction The direction the bullet will traverse the screen.
	 * @param damage The damage this bullet will inflict when it collides with an enemy.
	 * @param fadeDistance The distance this bullet will be able to travel before disappearing.
	 */
	public FadingBullet(Image image, Vector2f position, float speed,Vector2f direction, float damage,float fadeDistance) {
		super(image, position, speed, direction, damage);
		this.fadeDistance = fadeDistance;
		originalPosition = position.copy();
	}
	@Override
	protected void update(int delta){
		super.update(delta);
		if(this.position.copy().add(new Vector2f(-originalPosition.x,-originalPosition.y)).length() >= fadeDistance){
			this.remove();
		}
	}

}
